<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    如果config?.db?.password存在，则赋值给password，否则赋值为undefined
</body>
<script>
    // 可选链操作符
    let config = {
        db: {
            host: '192.168.1.100',
            port: 3306,
            user: 'root',
            password: '123456'
        }
    }
    // 如果config?.db?.password存在，则赋值给password，否则赋值为undefined
    let password = config?.db?.password;

    console.log(password);
</script>

</html>